export const baseUrl = 'https://hlx.xiangle6.cn'

export const request = (url, data, methods = 'post') => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + url,
			header: {
				Authorization: uni.getStorageSync('token')
			},
			method: methods,
			data: data,
			success(res) {
				if (res.data.code == 401) {
					uni.navigateTo({
						url: '/pages/my/my'
					})
					reject('401')
				}
				// if (res.data.code == 500) {
				// 	uni.showToast({
				// 		title: res.data.msg,
				// 		icon: 'none'
				// 	})
				// }
				resolve(res)
			},
			fail(err) {
				console.log(err)
				reject(err)
			}
		})
	})
}